<?xml version="1.0" encoding="UTF-8" ?>
<!--
	Converts the WSDL file to Objective-C for use in Cocoa applications.
-->
<xsl:stylesheet version="1.0"
	xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:s="http://www.w3.org/2001/XMLSchema"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns:tns="http://epm.aholdusa.com/webservices/"
	xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
	xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output version="1.0" encoding="iso-8859-1" method="xml" omit-xml-declaration="no" indent="yes"/>

	<xsl:variable name="soapPortName" select="/wsdl:definitions/wsdl:binding[soap:binding][1]/@name"/>
	<xsl:variable name="portType" select="/wsdl:definitions/wsdl:portType[@name = $soapPortName]"/>
	<xsl:param name="shortns"/>

	<xsl:template match="/">
		<package>
			<xsl:attribute name="name"><xsl:value-of select="/wsdl:definitions/wsdl:service/@name"/>.iPhone</xsl:attribute>
			<folder copy="ObjC/Soap"/>
			<folder copy="ObjC/TouchXML"/>
			<include copy="ObjC/README.rtf"/>
			<xsl:apply-templates/>
		</package>
	</xsl:template>

	<xsl:template name="imports">
#import "TouchXML.h"
#import "Soap.h";
#import "SoapFault.h";
#import "SoapObject.h";
#import "SoapHandler.h";
#import "SoapRequest.h";
	</xsl:template>


	<!-- MAIN TEMPLATE FOR ALL DEFINITIONS -->
	<xsl:template match="wsdl:definitions">
		<file>
			<xsl:attribute name="filename"><xsl:value-of select="wsdl:service/@name"/>.h</xsl:attribute>
/*
	<xsl:value-of select="wsdl:service/@name"/>.h
	The interface definition of classes and methods for the <xsl:value-of select="wsdl:service/@name"/> web service.
	Generated by SudzC.com
*/
			<xsl:call-template name="imports"/>
			<xsl:apply-templates select="wsdl:documentation"/>
/* Add class references */
			<xsl:apply-templates select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name]" mode="class_reference">
				<xsl:sort select="count(descendant::s:element[substring-before(@type, ':') != 's'])"/>
			</xsl:apply-templates>

/* Interfaces for complex objects */
			<xsl:apply-templates select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name and boolean(@abstract)]" mode="interface"/>
			<xsl:apply-templates select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name and not(boolean(@abstract))]" mode="interface">
				<xsl:sort select="count(descendant::s:element[substring-before(@type, ':') != 's'])"/>
			</xsl:apply-templates>

/* Interface for the service */
			<xsl:apply-templates select="wsdl:service" mode="interface"/>
		</file>


		<file>
			<xsl:attribute name="filename"><xsl:value-of select="wsdl:service/@name"/>.m</xsl:attribute>
/*
	<xsl:value-of select="wsdl:service/@name"/>.m
	The implementation classes and methods for the <xsl:value-of select="wsdl:service/@name"/> web service.
	Generated by SudzC.com
*/
			<xsl:call-template name="imports"/>
#import "<xsl:value-of select="wsdl:service/@name"/>.h"

/* Implementation for complex objects */
			<xsl:apply-templates select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name and boolean(@abstract)]" mode="implementation"/>
			<xsl:apply-templates select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name and not(boolean(@abstract))]" mode="implementation">
				<xsl:sort select="count(descendant::s:element[substring-before(@type, ':') != 's'])"/>
			</xsl:apply-templates>

/* Implementation of the service */
			<xsl:apply-templates select="wsdl:service" mode="implementation"/>
		</file>
	</xsl:template>



	<!-- DOCUMENTATION TEMPLATE -->
	<xsl:template match="wsdl:documentation">
/* <xsl:value-of select="."/> */
	</xsl:template>




	<!-- SERVICE INTERFACE AND IMPLEMENTATION -->
	<xsl:template match="wsdl:service" mode="interface">
@interface <xsl:value-of select="@name"/> : NSObject
{
	NSString* serviceUrl;
	NSString* namespace;
	BOOL logXMLInOut;
}

	@property (retain) NSString* serviceUrl;
	@property (retain) NSString* namespace;
	@property BOOL logXMLInOut;

		<xsl:apply-templates select="$portType/wsdl:operation" mode="interface"/>

@end
	</xsl:template>

	<xsl:template match="wsdl:service" mode="implementation">
@implementation <xsl:value-of select="@name"/>

	@synthesize serviceUrl, namespace, logXMLInOut;

	- (void) init
	{
		[super init];
		serviceUrl = @"<xsl:value-of select="wsdl:port/soap:address/@location"/>";
		namespace = @"<xsl:value-of select="/wsdl:definitions/@targetNamespace"/>";
		logXMLInOut = NO;
	}

		<xsl:apply-templates select="$portType/wsdl:operation" mode="implementation"/>

@end
	</xsl:template>

	<xsl:template match="wsdl:operation" mode="interface">
		<xsl:variable name="name" select="@name"/>
		<xsl:variable name="messageName">
			<xsl:value-of select="substring-after(wsdl:input/@message, ':')"/>
		</xsl:variable>
		<xsl:variable name="elementName">
			<xsl:value-of select="substring-after(/wsdl:definitions/wsdl:message[@name = $messageName]/wsdl:part/@element, ':')"/>
		</xsl:variable>
		<xsl:variable name="element" select="/wsdl:definitions/wsdl:types/s:schema/s:element[@name = $elementName]"/>

	- (void) <xsl:value-of select="$name"/>: (id &lt;SoapDelegate&gt;) handler <xsl:apply-templates select="$element" mode="param_selectors"/>;</xsl:template>

	<xsl:template match="wsdl:operation" mode="implementation">
		<xsl:variable name="name" select="@name"/>
		<xsl:variable name="messageName">
			<xsl:value-of select="substring-after(wsdl:input/@message, ':')"/>
		</xsl:variable>
		<xsl:variable name="elementName">
			<xsl:value-of select="substring-after(/wsdl:definitions/wsdl:message[@name = $messageName]/wsdl:part/@element, ':')"/>
		</xsl:variable>
		<xsl:variable name="element" select="/wsdl:definitions/wsdl:types/s:schema/s:element[@name = $elementName]"/>
		<xsl:variable name="action">
			<xsl:value-of select="/wsdl:definitions/wsdl:binding/wsdl:operation[@name = $name]/soap:operation/@soapAction"/>
		</xsl:variable>

		<xsl:apply-templates select="wsdl:documentation"/>
	- (void) <xsl:value-of select="$name"/>: (id &lt;SoapDelegate&gt;) handler<xsl:apply-templates select="$element" mode="param_selectors"/>
	{
		NSString* _soapAction = @"<xsl:value-of select="$action"/>";
    NSString* _envelope = [Soap createEnvelope:<xsl:apply-templates select="$element" mode="param_method"/> ofAction:_soapAction forNamespace:self.namespace containing:request];
		if(logXMLInOut) { NSLog(_envelope); }
		SoapRequest* _request = [SoapRequest create: handler urlString: serviceUrl soapAction: _soapAction postData: _envelope deserializeTo: <xsl:apply-templates select="wsdl:output" mode="object_name"/>];
		[_request send];
	}
	</xsl:template>

	<xsl:template match="s:element" mode="param_selectors">
		<xsl:for-each select="s:complexType/s:sequence/s:element">
			<xsl:value-of select="concat(' ', @name)"/>: (<xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template>) <xsl:value-of select="@name"/>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="s:element" mode="param_keys">
		<xsl:for-each select="s:complexType/s:sequence/s:element">@"<xsl:value-of select="@name"/>",</xsl:for-each>
	</xsl:template>

  <xsl:template match="s:element" mode="param_method">
    <xsl:for-each select="s:complexType/s:sequence/s:element">@"<xsl:value-of select="@name"/>"</xsl:for-each>
  </xsl:template>

	<xsl:template match="s:element" mode="param_values">
		<xsl:for-each select="s:complexType/s:sequence/s:element"><xsl:value-of select="@name"/>,</xsl:for-each>
	</xsl:template>

	<xsl:template match="wsdl:output" mode="object_name">
		<xsl:variable name="messageName">
			<xsl:value-of select="substring-after(@message, ':')"/>
		</xsl:variable>
		<xsl:variable name="elementName">
			<xsl:value-of select="substring-after(/wsdl:definitions/wsdl:message[@name = $messageName]/wsdl:part/@element, ':')"/>
		</xsl:variable>
		<xsl:variable name="element" select="/wsdl:definitions/wsdl:types/s:schema/s:element[@name = $elementName]"/>
		<xsl:variable name="type">
			<xsl:call-template name="getType">
				<xsl:with-param name="value" select="$element/s:complexType/s:sequence/s:element/@type"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="deserializer">
			<xsl:choose>
				<xsl:when test="$type = 'NSMutableArray*'"><xsl:value-of select="$shortns"/><xsl:value-of select="substring-after($element/s:complexType/s:sequence/s:element/@type, ':')"/></xsl:when>
				<xsl:otherwise><xsl:value-of select="substring-before($type, '*')"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="contains($type, '*')">[<xsl:value-of select="$deserializer"/> alloc]</xsl:when>
			<xsl:otherwise>nil</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<!-- COMPLEX TYPES INTERFACE AND IMPLEMENTATION -->

	<xsl:template match="s:complexType" mode="class_reference">
@class <xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>;</xsl:template>

	<xsl:template match="s:complexType" mode="interface">
		<xsl:choose>
			<xsl:when test="s:sequence/s:element[@maxOccurs = 'unbounded']">
				<xsl:apply-templates select="." mode="interface_array"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="." mode="interface_object"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="s:complexType" mode="implementation">
		<xsl:choose>
			<xsl:when test="s:sequence/s:element[@maxOccurs = 'unbounded']">
				<xsl:apply-templates select="." mode="implementation_array"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="." mode="implementation_object"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="s:complexType" mode="interface_object">
		<xsl:variable name="baseType">
			<xsl:choose>
				<xsl:when test="descendant::s:extension[@base]">
					<xsl:value-of select="$shortns"/><xsl:value-of select="substring-after(descendant::s:extension/@base, ':')"/>
				</xsl:when>
				<xsl:otherwise>SoapObject</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
@interface <xsl:value-of select="$shortns"/><xsl:value-of select="@name"/> : <xsl:value-of select="$baseType"/>
{
	<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="interface_variables"/>
}
		<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="interface_properties"/>

	+ (<xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>*) newWithNode: (CXMLNode*) node;
  - (id) initWithNode: (CXMLNode*) node;
  - (NSMutableString*) serialize;

@end
  </xsl:template>

	<xsl:template match="s:complexType" mode="implementation_object">
@implementation <xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>
		<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="implementation_synthesize"/>

	- (id) init
	{
		if(self = [super init])
		{
			<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="implementation_alloc"/>
		}
		return self;
	}

	+ (<xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>*) newWithNode: (CXMLNode*) node
	{
		return (<xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>*)[[<xsl:value-of select="$shortns"/><xsl:value-of select="@name"/> alloc] initWithNode: node];
	}

	- (id) initWithNode: (CXMLNode*) node {
		if(self = [super initWithNode: node])
		{<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="implementation"/>
    }
    return self;
    }

    - (NSMutableString*) serialize
    {
    NSMutableString* s = [super serialize];
    <xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="implementation_serialize"/>
  //  [s appendString: [Soap serialize: self]];
    return s;
    }

    - (void) dealloc
    {<xsl:apply-templates select="descendant::s:element|descendant::s:attribute" mode="dealloc"/>
		[super dealloc];
	}

@end
	</xsl:template>

	<xsl:template match="s:complexType" mode="interface_array">
@interface <xsl:value-of select="$shortns"/><xsl:value-of select="@name"/> : SoapObject
{
	NSMutableArray *items;
}
	@property (retain, nonatomic) NSMutableArray *items;
	+ (NSMutableArray*) newWithNode: (CXMLNode*) node;
	- (NSMutableArray*) initWithNode: (CXMLNode*) node;

@end
	</xsl:template>

	<xsl:template match="s:complexType" mode="implementation_array">
		<xsl:variable name="declaredType"><xsl:call-template name="getType"><xsl:with-param name="value" select="descendant::s:element/@type"/></xsl:call-template></xsl:variable>
@implementation <xsl:value-of select="$shortns"/><xsl:value-of select="@name"/>
	@synthesize items;
	+ (NSMutableArray*) newWithNode: (CXMLNode*) node
	{
		return (NSMutableArray*)[[<xsl:value-of select="$shortns"/><xsl:value-of select="@name"/> alloc] initWithNode: node];
	}
	- (NSMutableArray*) initWithNode: (CXMLNode*) node
	{
		[super initWithNode: node];
		items = [[NSMutableArray alloc] init];
		for(CXMLElement* child in [node children])
		{
			<xsl:value-of select="$declaredType"/> value = <xsl:choose>
				<xsl:when test="$declaredType = 'NSString*'">[child stringValue];</xsl:when>
				<xsl:when test="$declaredType = 'BOOL'">[[child stringValue] boolValue];</xsl:when>
				<xsl:when test="$declaredType = 'int'">[[child stringValue] intValue];</xsl:when>
				<xsl:when test="$declaredType = 'long'">[[child stringValue] longLongValue];</xsl:when>
				<xsl:when test="$declaredType = 'double'">[[child stringValue] doubleValue];</xsl:when>
				<xsl:when test="$declaredType = 'float'">[[child stringValue] floatValue];</xsl:when>
				<xsl:when test="$declaredType = 'NSDecimalNumber*'">[NSDecimalNumber decimalNumberWithString: [child stringValue]];</xsl:when>
				<xsl:when test="$declaredType = 'NSDate*'">[NSDate dateWithString: [child stringValue]];</xsl:when>
				<xsl:otherwise>[<xsl:value-of select="substring-before($declaredType, '*')"/> newWithNode: child];</xsl:otherwise>
			</xsl:choose>
			if(value != nil) {
				[items addObject: value];
			}
			[value release];
		}
		return items;
	}
	- (void) dealloc
	{
		[super dealloc];
	}
@end
	</xsl:template>

	<xsl:template match="s:element|s:attribute" mode="interface_variables">
		<xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template><xsl:value-of select="' '"/><xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template>;
	</xsl:template>

	<xsl:template match="s:element|s:attribute" mode="interface_properties">
		<xsl:variable name="type">
			<xsl:call-template name="getType">
				<xsl:with-param name="value" select="@type"/>
			</xsl:call-template>
		</xsl:variable>
	@property <xsl:if test="contains($type, '*')">(retain, nonatomic)</xsl:if><xsl:value-of select="concat(' ', $type)"/> <xsl:value-of select="' '"/><xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template>;</xsl:template>

	<xsl:template match="s:element|s:attribute" mode="implementation_synthesize">
	@synthesize <xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template>;</xsl:template>

	<xsl:template match="s:element|s:attribute" mode="implementation_alloc">
		<xsl:variable name="type"><xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template></xsl:variable>
		<xsl:variable name="name"><xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template></xsl:variable>
		<xsl:if test="contains($type,'*')">
			<xsl:choose>
				<xsl:when test="$type = 'NSMutableArray*'">self.<xsl:value-of select="$name"/> = [[<xsl:value-of select="translate($type,'*','')"/> alloc] init];</xsl:when>
				<xsl:when test="starts-with($type,'NS')">self.<xsl:value-of select="$name"/> = nil;</xsl:when>
				<xsl:otherwise>self.<xsl:value-of select="$name"/> = [[<xsl:value-of select="translate($type,'*','')"/> alloc] init];</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>

  <!-- addition to create serialize methods for each sub class -->
  <xsl:template match="s:element|s:attribute" mode="implementation_serialize">
    <xsl:variable name="type"><xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template></xsl:variable>
    <xsl:variable name="name"><xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template></xsl:variable>
    <xsl:choose>
      <xsl:when test="$type = 'NSString*'">if (self.<xsl:value-of select="$name"/> != nil) [s appendFormat:@&quot;&lt;%@&gt;%@&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'BOOL'">[s appendFormat:@&quot;&lt;%@&gt;%@&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, (self.<xsl:value-of select="$name"/>)?@&quot;1&quot;:@&quot;0&quot;, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'int'">[s appendFormat:@&quot;&lt;%@&gt;%i&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'long'">[s appendFormat:@&quot;&lt;%@&gt;%ld&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'double'">[s appendFormat:@&quot;&lt;%@&gt;%d&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'float'">[s appendFormat:@&quot;&lt;%@&gt;%f&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'NSDecimalNumber*'">if (self.<xsl:value-of select="$name"/> != nil) [s appendFormat:@&quot;&lt;%@&gt;%@&lt;%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'NSDate*'">if (self.<xsl:value-of select="$name"/> != nil) [s appendFormat:@&quot;&lt;%@&gt;%@&lt;%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, self.<xsl:value-of select="$name"/>, @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:when>
      <xsl:when test="$type = 'NSMutableArray*'">
        if (self.<xsl:value-of select="$name"/> != nil) [s appendFormat:@&quot;&lt;%@&gt;&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, @&quot;<xsl:value-of select="$name"/>&quot;];
        /* insert loop hear to serialize elements in array */
      </xsl:when>
      <xsl:otherwise>
        [s appendFormat:@&quot;&lt;%@&gt;%@&lt;/%@&gt;&quot;,@&quot;<xsl:value-of select="$name"/>&quot;, [self.<xsl:value-of select="$name"/> serialize], @&quot;<xsl:value-of select="$name"/>&quot;];
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

	<xsl:template match="s:element|s:attribute" mode="implementation">
		<xsl:variable name="type"><xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template></xsl:variable>
			self.<xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template> = <xsl:call-template name="getNodeValue"><xsl:with-param name="declaredType" select="$type"/><xsl:with-param name="actualType" select="@type"/><xsl:with-param name="name" select="@name"/></xsl:call-template>;</xsl:template>
	
	<xsl:template match="s:element|s:attribute" mode="dealloc">
		<xsl:variable name="type"><xsl:call-template name="getType"><xsl:with-param name="value" select="@type"/></xsl:call-template></xsl:variable>
		<xsl:variable name="name"><xsl:call-template name="getName"><xsl:with-param name="value" select="@name"/></xsl:call-template></xsl:variable>
		<xsl:if test="contains($type,'*')">
		if(self.<xsl:value-of select="$name"/> != nil) { [self.<xsl:value-of select="$name"/> release]; }</xsl:if>
	</xsl:template>

	<xsl:template name="getNodeValue">
		<xsl:param name="name"/>
		<xsl:param name="declaredType"/>
		<xsl:param name="actualType"/>
		<xsl:choose>
			<xsl:when test="$declaredType = 'NSString*'">[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"]</xsl:when>
			<xsl:when test="$declaredType = 'BOOL'">[[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"] boolValue]</xsl:when>
			<xsl:when test="$declaredType = 'int'">[[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"] intValue]</xsl:when>
			<xsl:when test="$declaredType = 'long'">[[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"] longLongValue]</xsl:when>
			<xsl:when test="$declaredType = 'double'">[[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"] doubleValue]</xsl:when>
			<xsl:when test="$declaredType = 'float'">[[Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"] floatValue]</xsl:when>
			<xsl:when test="$declaredType = 'NSDecimalNumber*'">[NSDecimalNumber decimalNumberWithString: [Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"]]</xsl:when>
			<xsl:when test="$declaredType = 'NSDate*'">[NSDate dateWithString: [Soap getNodeValue: node withName: @"<xsl:value-of select="$name"/>"]]</xsl:when>
			<xsl:otherwise>[<xsl:value-of select="$shortns"/><xsl:value-of select="substring-after($actualType, ':')"/> newWithNode: [Soap getNode: node withName: @"<xsl:value-of select="$name"/>"]]</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="getName">
		<xsl:param name="value"/>
		<xsl:variable name="property" select="translate($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
		<xsl:choose>
			<xsl:when test="$property = 'id'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'entertainment'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'location'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'category'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'action'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'collection'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'size'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:when test="$property = 'point'"><xsl:value-of select="$value"/>Value</xsl:when>
			<xsl:otherwise><xsl:value-of select="$value"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="getType">
		<xsl:param name="value"/>
		<xsl:variable name="type" select="substring-after($value,':')"/>
		<xsl:variable name="complexType" select="/wsdl:definitions/wsdl:types/s:schema/s:complexType[@name = $type]"/>
		<xsl:variable name="isArray" select="$complexType/s:sequence/s:element[@maxOccurs = 'unbounded']"/>
		<xsl:choose>
			<xsl:when test="$isArray">NSMutableArray*</xsl:when>
			<xsl:when test="$complexType"><xsl:value-of select="$shortns"/><xsl:value-of select="$type"/>*</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$type = 'string'">NSString*</xsl:when>
					<xsl:when test="$type = 'normalizedString'">NSString*</xsl:when>
					<xsl:when test="$type = 'token'">NSString*</xsl:when>
					<xsl:when test="$type = 'integer'">int</xsl:when>
					<xsl:when test="$type = 'int'">int</xsl:when>
					<xsl:when test="$type = 'positiveInteger'">int</xsl:when>
					<xsl:when test="$type = 'negativeInteger'">int</xsl:when>
					<xsl:when test="$type = 'nonPositiveInteger'">int</xsl:when>
					<xsl:when test="$type = 'nonNegativeInteger'">int</xsl:when>
					<xsl:when test="$type = 'long'">long</xsl:when>
					<xsl:when test="$type = 'unsignedLong'">long</xsl:when>
					<xsl:when test="$type = 'short'">short</xsl:when>
					<xsl:when test="$type = 'unsignedShort'">short</xsl:when>
					<xsl:when test="$type = 'float'">float</xsl:when>
					<xsl:when test="$type = 'double'">double</xsl:when>
					<xsl:when test="$type = 'byte'">byte</xsl:when>
					<xsl:when test="$type = 'unsignedByte'">byte</xsl:when>
					<xsl:when test="$type = 'decimal'">NSDecimalNumber*</xsl:when>
					<xsl:when test="$type = 'boolean'">BOOL</xsl:when>
					<xsl:when test="$type = 'dateTime'">NSDate*</xsl:when>
					<xsl:when test="$type = 'date'">NSDate*</xsl:when>
					<xsl:when test="$type = 'time'">NSDate*</xsl:when>
					<xsl:otherwise>NSString*</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

</xsl:stylesheet>
